#include <iostream>
#include <vector>
using namespace std;

long long getTime(const vector<int>& piles, int speed){
    long long ans = 0;
    for(int p : piles) ans += (p+speed-1) / speed;
    return ans;
}

int minEatingSpeed(vector<int>& piles, int h) {
    int l = 1, r = 0, mid;
    for(int p : piles) r = max(r, p);
    while(l <= r){
        mid = l + (r - l) / 2;
        if(getTime(piles, mid) > h) l = mid + 1;
        else r = mid - 1;
    }
    return l;
}